package com.iims.market.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.iims.common.core.domain.BaseEntity;
import com.iims.common.core.domain.BussinessEntity;
import com.iims.market.vo.ContractReqInfoVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @TableName cmis_contract_purpose
 */
@ApiModel("意向合同")
@Data
@TableName(value = "cmis_contract_purpose")
@BussinessEntity
public class PurposeContract extends BaseEntity {

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "意向合同Id")
    private Long purposeContractId;

    @ApiModelProperty(value = "合同来源:值来源于字典contract_from", required = true)
    @NotBlank(message = "合同来源不能为空")
    private String ctraFrom;

    @ApiModelProperty(value = "产品属性:值来源于字典contract_pro_attribute", required = true)
    @NotBlank(message = "产品属性不能为空")
    private String proAtrr;

    @ApiModelProperty(value = "合同名称:长度不超过255字符",required = true)
    @NotBlank(message = "合同名称不能为空")
    @Size(min = 0, max = 255, message = "合同名称长度不超过255字符")
    private String contractName;


    @ApiModelProperty(value = "合同编号:长度不超过32字符", required = true)
    @NotBlank(message = "意向合同编号不能为空")
    @Size(min = 0, max = 32, message = "长度不超过32字符")
    private String pcontractCode;

    /**
     * 0：意向合同 1：正式合同
     */
    @ApiModelProperty(hidden = true)
    private Byte isOfficial = 0;

    @ApiModelProperty(value = "客户id", required = true)
    @Positive(message = "客户Id必须有效 >0")
    private Long customerId;

    @ApiModelProperty(value = "合同类型id", required = true)
    @Positive(message = "合同类型Id必须有效 >0")
    private Integer ctraTypeId;

    @ApiModelProperty(value = "正式合同编号:长度不超过32字符", hidden = true)
    @Size(min = 0, max = 32, message = "长度不超过32字符")
    private String contractCode;


    @ApiModelProperty(value = "转换时间", hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date changeTime;


    @ApiModelProperty(value = "预计签订时间：yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date probablySignDate;

    @ApiModelProperty(value = "要求交期：yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date probablyDeliveryDate;


    @ApiModelProperty(value = "预计金额/元:最大12位整数2位小数")
    @Column(length = 14, scale = 2)
    private BigDecimal probablySellMoney;

    @ApiModelProperty(value = "销售负责人（user_code）")
    private String sellUserCode;

    //扩展信息Json
    @ApiModelProperty(hidden = true)
    @JsonIgnore
    private String extentions;

    //vo
    @ApiModelProperty(value = "合同需求信息")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @TableField(exist = false)
    private ContractReqInfoVo contractReqInfo;

    @ApiModelProperty("销售负责人[中文]")
    @TableField(exist = false)
    private String sellUser;

    @ApiModelProperty("类型名称[中文]")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @TableField(exist = false)
    private String ctraTypeName;

    @ApiModelProperty("客户名称[中文]")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @TableField(exist = false)
    private String customerName;

}